Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the SqliteReportBuilderTx indirection #8

Closed

Conversation

Swatinem
Copy link
Collaborator

This removes the SqliteReportBuilderTx as it was effectively unused and an unnecessary indirection.

All users were going through the main SqliteReportBuilder, which was using a transaction for each method anyway.

Depending on the plans for error handling, a whole report (builder) should be constructed without errors for it to be internally consistent anyway, so the ability to rollback transactions with an arbitrary granularity does not make sense for now.

@Swatinem Swatinem requested a review from matt-codecov July 24, 2024 11:08
@Swatinem Swatinem self-assigned this Jul 24, 2024
@Swatinem Swatinem changed the title Remove BuilderTx indirection Remove the SqliteReportBuilderTx indirection Jul 24, 2024
@matt-codecov
Copy link
Collaborator

matt-codecov commented Jul 26, 2024

you're right that this is untidy, but there's a lifetime issue that makes doing what we need to do here tricky

we actually want SqliteReportBuilder to do all of its operations in a shared transaction, not one per method call, because it's way more performant. we use .transaction() in the entrypoint for parsing a pyreport. trouble is, SqliteReportBuilder owns its rusqlite::Connection, and a rusqlite::Transaction has a ref to its rusqlite::Connection. a struct can't have a field that references another one of its fields, so SqliteReportBuilder is unable to also own a rusqlite::Transaction

this was a little while ago so i don't remember my whole thought process, but iirc i thought moving ownership of the rusqlite::Connection up a level and needing to make SqliteReportBuilder go out of scope before the caller can make a SqliteReport was really awkward. this is a lot more boilerplate, but design-wise it felt a little more sound

i don't like where i left this though, so changes are welcome

@matt-codecov matt-codecov force-pushed the matt/replace-uuid-and-batch-insert branch from c26f8f3 to c434444 Compare July 27, 2024 02:32
This removes the `SqliteReportBuilderTx` as it was effectively unused and an unnecessary indirection.

All users were going through the main `SqliteReportBuilder`, which was using a transaction for each method anyway.

Depending on the plans for error handling, a whole report (builder) should be constructed without errors for it to be internally consistent anyway, so the ability to rollback transactions with an arbitrary granularity does not make sense for now.
@Swatinem Swatinem force-pushed the swatinem/rm-transaction branch from 00df4ae to f8c6d63 Compare July 29, 2024 08:36
@Swatinem
Copy link
Collaborator Author

Oh, I see that I missed this primary usage when looking at it. I will close this, as it does not make sense.

@Swatinem Swatinem closed this Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants